<template>
  <div class="app-container">
    <table-list
      ref="tableList"
      :fields="tableDataColumn"
      :pagination="true"
      :searchFunc="bankVerificationGetList"
      :searchDefault="searchConditions"
      border></table-list>
  </div>
</template>
<script>
import TableList from '@/components/TableList/index';
import Detail from '@/views/product/bank/detail';
import { bankVerificationGetList } from '@/api/product';
import { getList as getUserList } from '@/api/user';
export default {
  name: 'portraitComparison',
  components: {
    TableList,
  },
  props: {
    product: {
      type: Object,
      default: null,
    },
  },
  data() {
    return {
      bankVerificationGetList,
    };
  },
  computed: {
    searchConditions() {
      return {
        product_no: this.product.product_no,
      };
    },
    showPhone() {
      if (this.product.product_no === 'P_004_0071') {
        return false;
      }
      return true;
    },
    tableDataColumn() {
      return [
        {
          prop: 'id',
          label: '序号',
          minWidth: '80',
        },
        {
          prop: 'name',
          searchName: 'name',
          label: '姓名',
          minWidth: '120',
          searchType: 'input',
          baseSeachColumn: true,
        },
        {
          prop: 'phone',
          searchName: 'phone',
          label: '手机号码',
          minWidth: '120',
          searchType: 'input',
          showField: this.showPhone,
        },
        {
          prop: 'id_card',
          searchName: 'id_card',
          label: '身份证',
          minWidth: '180',
          searchType: 'input',
        },
        {
          prop: 'bank_card_no',
          searchName: 'bank_card_no',
          label: '银行卡号',
          minWidth: '180',
          searchType: 'input',
        },
        {
          prop: 'status',
          searchName: 'status',
          label: '状态',
          options: [
            {
              value: 100,
              label: '成功',
              color: '#67C23A',
            },
            {
              value: 0,
              label: '失败',
              color: '#F56C6C',
            },
          ],
          minWidth: '120',
          searchType: 'select',
        },
        {
          prop: 'message',
          searchName: 'message',
          label: '描述',
          minWidth: '120',
        },
        {
          prop: 'is_charge',
          searchName: 'is_charge',
          label: '收费',
          searchType: 'select',
          options: [
            {
              value: 1,
              label: '扣费',
              color: '#67C23A',
            },
            {
              value: 0,
              label: '不扣费',
              color: '#F56C6C',
            },
          ],
          minWidth: '120',
        },
        {
          prop: 'user.nick_name',
          searchName: 'user_id',
          label: '用户',
          minWidth: '120',
          searchType: 'remoteSelect',
          searchAction: getUserList,
          searchKey: 'id',
          searchLabel: 'nick_name',
          exact: true,
        },
        {
          prop: 'created_at',
          searchName: 'created_at',
          label: '创建时间',
          minWidth: '180',
          searchType: 'dateTime',
        },
        {
          label: '操作',
          searchField: false,
          render: (h, scope) => {
            return (
              <div>
                <el-button
                  size='mini'
                  type='text'
                  onClick={() => {
                    this.showDetailAction(scope.row);
                  }}>
                  查看
                </el-button>
              </div>
            );
          },
          fixed: 'right',
          minWidth: '160',
        },
      ];
    },
  },
  methods: {
    showDetailAction(row) {
      this.$createDialog({
        title: '详情',
        component: Detail,
        width: '40%',
        props: {
          formData: row,
          showPhone: this.showPhone,
        },
        buttons: [{ text: '关闭', callback: 'handleSubmit', name: 'submit' }],
      });
    },
  },
};
</script>